$(function () {
    $.ajax({
        url: 'http://localhost:8080/cart/showCart',
        type: 'post',
        data: loginUser,
        dataTypt: 'json',
        timeout: '1000',
        cache: 'false',
        error: erryFunction,
        success: succFunction
    })

    function erryFunction() {
        alert("请求错误");
    }

    0

    function succFunction(data) {
        let loginUser = getLoginUser();

        var total;
        for (var cart in data) {
            $("#cartContent").append('<tr>\n' +
                '<th type="checkbox"></th>' +
                '                <th><img width="300px" height="300px" src="' + cart.img + '"></th>' +
                '                <th>' + cart.courseId + '</th>\n' +
                '                <th>' + cart.price + '</th>\n' +
                '            </tr>');
            total += cart.price;
        }
        $("#total").text(total);
    }
});

/* $(function () {
     $.ajax({
         url: '/cart/showCart?userId=1',
         type: 'GET',
         dataTypt: 'json',
         timeout: '1000',
         cache: 'false',
         error: erryFunction,
         success: succFunction
     })

     function erryFunction() {
         alert("请求错误");
     }

     function succFunction(data) {
         let loginUser = getLoginUser();

         var total;
         for (var cart in data) {
             $("#cartContent").append('<tr>\n' +
                 '<th type="checkbox"></th>' +
                 '                <th><img width="300px" height="300px" src="' + cart.img + '"></th>' +
                 '                <th>' + cart.courseId + '</th>\n' +
                 '                <th>' + cart.price + '</th>\n' +
                 '            </tr>');
             total += cart.price;
         }
         $("#total").text(total);
     }
 });
*/
/*
    $(function () {
    $.ajax({
        type: "GET",
        url: "http://localhost:8080/web/",//参数url,要把参数传到什么地方
        data: {parentid: parentid, parentpath: parentpath},//传递什么数据
        success: function (data) {//sucess表示，当数据返回成功后要怎么做，返回的数据存储在data {
            console.log(data);
            console.log(typeof (data));
            var data = res.result;
            console.log(data);
            var str = '';
            // 注意：输出的i与obj分别为下标与单个的对象
            $.each(data, function (i, obj) {
                // console.log(i);
                // console.log(obj);
                str += '<div class="inner">';
                str += '<img src="' + obj.imgUrl + '"/>';
                str += '<h3>' + '名称：' + obj.name + '</h3>';
                str += '<span>' + '价格：￥' + obj.price + '</span>';
                str += '</div>';
            });
            $("#test").append(str);

        }
    });
});*/
